import java.util.Scanner;
//公共字符串计算
public class test {
    import java.util.*;
    public class Main{
        public static void main(String[]args){
            Scanner sc=new Scanner(System.in);
            String str1=sc.nextLine();
            String str2=sc.nextLine();
            System.out.println(getMaxLen(str1,str2));
        }
        public static int getMaxLen(String str1,String str2){
            char[]arr1=str1.toCharArray();
            char[]arr2=str2.toCharArray();
            int len1=arr1.length;
            int len2=arr2.length;
            int maxLen=0;
            int[][]maxSubLen=new int[len1+1][len2+1];
            for(int i=1;i<=len1;i++){
                for(int j=1;j<=len2;j++){
                    if(arr1[i-1]==arr2[j-1]){
                        //状态转移方程
                        maxSubLen[i][j]=maxSubLen[i-1][j-1]+1;
                    }
                    //更新最大值
                    if(maxLen<maxSubLen[i][j]){
                        maxLen=maxSubLen[i][j];
                    }
                }
            }
            return maxLen;
        }
    }
}
